Skip to content

ci(regen): rustfmt generated code so regen diffs stay reviewable#46

Merged
zfarrell merged 2 commits into
mainfrom
ci/rustfmt-regenerated-code
Jun 6, 2026
Merged

ci(regen): rustfmt generated code so regen diffs stay reviewable#46
zfarrell merged 2 commits into
mainfrom
ci/rustfmt-regenerated-code

Conversation

@zfarrell

@zfarrell zfarrell commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

Generator 7.22.0 emits compact, non-rustfmt output, so regen diffs are dominated by formatting churn (PR #44 was 157 files / ~3300 lines, ~95% reformatting). Adds a rustfmt pass over the generated subtrees (src/apis, src/models) after generate — leaving the hand-written layer alone — so future regen diffs show only semantic changes. Verified by reformatting #44: its diff collapsed to 11 code files / +482-3.

Comment thread .github/workflows/regenerate.yml Outdated
# ergonomic layer is left to its own formatting (and is ignore-protected
# from the generator anyway).
- name: Format generated code
run: find src/apis src/models -name '*.rs' -print0 | xargs -0 rustfmt --edition 2021

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super nit: --edition 2021 is hardcoded here while the edition is also declared in Cargo.toml (edition = "2021"). If the crate edition is ever bumped, this will silently drift and format the generated code under the old edition's rules. Not worth a cargo fmt (which would touch the hand-written layer you're deliberately excluding), but you could derive it from Cargo.toml to keep them in sync, e.g. --edition "$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[] | select(.name=="hotdata") | .edition')". (not blocking)

claude[bot]
claude Bot previously approved these changes Jun 6, 2026

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean, focused change. Adds the rustfmt component and formats only the generated subtrees, keeping future regen diffs reviewable. The verify-step greps target short lines that rustfmt won't reflow, so they remain intact. One non-blocking super-nit left inline.

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Edition is now derived from Cargo.toml as suggested. The rustfmt pass is correctly scoped to the generated subtrees and uses null-delimited filename handling. LGTM.

@zfarrell zfarrell merged commit 0eb4c6d into main Jun 6, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant